<template>
  <div class="deposit-detail-wrap">
    <div class="deposit-bank-money-box">
      <div class="deposit-bank-money">
        <div class="bank-logo">
          <img src="./bank.png" class="pic" onclick="return false"/>
        </div>
        <div class="bank-info">
          <span class="bank-name">{{bankName}}</span>
          <span class="bank-num">尾号{{bankNum}}{{cardType}}</span>
        </div>
        <div class="money-box">
          <span class="money-con1">￥{{depositMoney}}</span>
          <span class="money-con2">手续费：{{chargeMoney}}元</span>
        </div>
      </div>
      <div class="account-money" v-if="chargeMoney > 0">实际到账：{{accountMoney}}元</div>
    </div>

    <div class="line-box"></div>

    <div class="deposit-apply-process">
      <span class="process-title">提现进度</span>

      <div class="process-box">

        <div class="process-start">
          <img src="../../images/P_2.png" class="pic1"/>
          <div class="process-start-con">
            <span class="process-text">提现已发起</span>
            <span class="process-time">{{applyTime}}</span>
          </div>
        </div>

        <div :class="{'process-active-suc-line':status != 4,'process-active-err-line':status == 4}"></div>

        <div class="process-start process-end">
          <img src="../../images/p_1.png" class="pic1" v-if="status == 1 || status == 2"/>
          <img src="../../images/P_2.png" class="pic1" v-else-if="status == 3"/>
          <img src="../../images/P_3.png" class="pic1" v-else-if="status == 4"/>

          <div class="process-start-con">
            <span class="process-text" v-if="status == 1 || status == 2">银行处理中</span>
            <span class="process-text" v-else-if="status == 3">提现成功</span>
            <div class="process-text error-text" v-else-if="status == 4">提现失败<span v-if="remark">（理由：{{remark}}）</span>
            </div>
            <span class="process-time" v-show="status == 3 || status == 4">{{endTime}}</span>
          </div>
        </div>

      </div>

      <div class="deposit-tip">
        <span>注：</span>
        <span>预计2个小时内到账，具体到账时间请留意银行短信通知。</span>
      </div>
    </div>

    <back-page @backPage="backPage"></back-page>
  </div>
</template>

<script>
  import {queryDepositOrBillRecord} from "../../axios/api";
  import {formatDate, toDecimal} from "../../config/util";
  import backPage from "../../components/backPage";

  export default {
    data() {
      return {
        depositId: this.$route.query.depositId,
        userMark: "",
        applyTime: "",
        remark: "",
        status: "",
        endTime: "",
        depositMoney: "",
        cardType: "",
        bankNum: "",
        bankName: "",
        chargeMoney: "",
        accountMoney: ""
      }
    },
    created() {
      let base64 = require('js-base64').Base64;
      this.userMark = base64.decode(sessionStorage.getItem("userMark"));
      this.queryDepositRecord();
    },
    methods: {
      queryDepositRecord() {
        let params = {
          "sgin": this.userMark,
          "id": this.depositId,
          "type": 2,  //1账单详情,2提现进度
        };
        queryDepositOrBillRecord(params).then((res) => {
          if (res.code == 0 && res.data != null) {
            this.accountMoney = toDecimal(res.data.money);//到账金额
            this.bankNum = res.data.bankNum;//银行卡后四位
            this.bankName = res.data.bankName;//银行卡名称
            this.remark = res.data.errorRemark;//提现失败err
            this.applyTime = formatDate(new Date(res.data.time), 'yyyy-MM-dd hh:mm');
            this.endTime = formatDate(new Date(res.data.set_time), 'yyyy-MM-dd hh:mm');
            this.status = res.data.status;//1提现申请2银行接受处理3银行处理成功4银行转账失败
            this.chargeMoney = toDecimal(res.data.chargeMoney);//手续费
            this.cardType = res.data.cardType;//卡片类型
            this.depositMoney = toDecimal(Math.floor(parseFloat(((res.data.money + res.data.chargeMoney) * 100).toString())) / 100);//提现金额
          } else {
            this.$vux.toast.text(res.msg, "middle");
          }
        });
      },
      backPage() {
        this.$router.push("/mine");
      }
    },
    components: {
      backPage
    }
  }
</script>

<style lang="less" scoped>
  @import "../../assest/mixin";

  .deposit-detail-wrap {
    .wh(100%, 100%);
    background: #FFF;
    overflow: hidden;
    .deposit-bank-money-box {
      display: flex;
      flex-direction: column;
      margin-top: 0.24rem;
      .wh(100%, auto);
      .deposit-bank-money {
        display: flex;
        .wh(100%, 1.28rem);
        align-items: center;
        .bank-logo {
          padding-left: 0.32rem;
          .pic {
            .wh(1.28rem, 1.28rem);
          }
        }
        .bank-info {
          display: flex;
          flex-direction: column;
          padding-left: 0.467rem;
          .bank-name {
            .ellipsis(5.067rem);
            .size-color-weight(0.427rem, rgba(51, 51, 51, 1), 500);
            padding-bottom: 0.2rem;
          }
          .bank-num {
            .size-color(0.347rem, rgba(153, 153, 153, 1));
          }
        }
        .money-box {
          display: flex;
          flex-direction: column;
          margin-left: auto;
          margin-right: 0.36rem;
          align-items: flex-end;
          .money-con1 {
            padding-bottom: 0.2rem;
            .size-color-weight(0.48rem, rgba(60, 175, 255, 1), 500);
          }
          .money-con2 {
            .size-color(0.347rem, rgba(153, 153, 153, 1));
          }
        }
      }
      .account-money {
        display: flex;
        margin-left: auto;
        margin-right: 0.36rem;
        padding-bottom: 0.4rem;
        .size-color(0.347rem, rgba(153, 153, 153, 1));
      }
    }
    .line-box {
      .wh(100%, 0.267rem);
      background: @talent-theme-bg-color;
    }
    .deposit-apply-process {
      display: flex;
      flex-direction: column;
      .process-title {
        margin-left: 0.32rem;
        margin-bottom: 0.867rem;
        text-align: center;
        line-height: 0.64rem;
        .wh(1.973rem, 0.64rem);
        background: rgba(255, 166, 61, 1);
        border-bottom-left-radius: 0.107rem;
        border-bottom-right-radius: 0.107rem;
        .size-color(0.373rem, rgba(255, 255, 255, 1));
      }
      .process-box {
        position: relative;
        .process-start {
          display: flex;
          align-items: flex-start;
          height: 0.867rem;
          padding-left: 0.44rem;
          .pic1 {
            .wh(0.4rem, 0.4rem);
          }
          .process-start-con {
            margin-left: 0.44rem;
            display: flex;
            flex-direction: column;
            .process-text {
              padding-bottom: 0.2rem;
              .size-color(0.427rem, rgba(60, 175, 255, 1));
            }
            .error-text {
              color: #FF5353;
            }
            .process-time {
              .size-color(0.32rem, rgba(153, 153, 153, 1));
            }
          }
        }
        .process-end {
          padding-top: 1.8rem;
        }
        .process-active-suc-line {
          position: absolute;
          top: 0.2rem;
          margin-left: 0.627rem;
          .wh(0.027rem, 2.667rem);
          background: rgba(60, 175, 255, 1);
        }
        .process-active-err-line {
          position: absolute;
          top: 0.3rem;
          margin-left: 0.627rem;
          width: 0.027rem;
          height: 2.45rem;
          background: #FFCBCB;
        }
      }
      .deposit-tip {
        display: flex;
        padding-top: 1.2rem;
        line-height: 0.4rem;
        .size-color(0.373rem, rgba(153, 153, 153, 1));
        span {
          &:nth-child(1) {
            margin-left: 0.453rem;
          }
          &:nth-child(2) {
            margin-left: 0.05rem;
            width: 8.34rem;
          }
        }
      }
    }
  }
</style>
